﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using QLT_BLL;
using QLT_Public;
using QLThuoc_report;

namespace GiaoDien
{
    public partial class uc_ThongKe_ThuocNhapTheoThang : DevExpress.XtraEditors.XtraUserControl
    {
        public uc_ThongKe_ThuocNhapTheoThang()
        {
            InitializeComponent();
        }
        ThongKe_BLL thongke_bll = new ThongKe_BLL();

        private void uc_ThongKe_ThuocNhapTheoThang_Load(object sender, EventArgs e)
        {
            gridControl1.DataSource = thongke_bll.Load_ThongKe_ThuocNhapTheoThang();
        }

        private void btnTimKiem_Click(object sender, EventArgs e)
        {
            if (txtThang.Text != "" && txtNam.Text != "")
            {
                string m = txtThang.Text, y = txtNam.Text;
                gridControl1.DataSource = thongke_bll.ThongKe_ThuocNhap_TheoThang(m, y);
            }
            else
                XtraMessageBox.Show("Bạn chưa nhập đủ dữ liệu!");
        }

        private void txtThang_Leave(object sender, EventArgs e)
        {
            if (txtThang.Text == "")
                txtThang.Focus();
        }

        private void txtNam_Leave(object sender, EventArgs e)
        {
            if (txtNam.Text == "")
                txtNam.Focus();
        }

        private void txtNam_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!Char.IsControl(e.KeyChar) && !Char.IsDigit(e.KeyChar))
                e.Handled = true;
        }

        private void txtThang_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!Char.IsControl(e.KeyChar) && !Char.IsDigit(e.KeyChar))
                e.Handled = true;
        }

        private void bbi_In_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (txtThang.Text != "" && txtNam.Text != "")
            {
                //Frm_TkeThuocNhapTheoThang f = new Frm_TkeThuocNhapTheoThang();
                Frm_TkeThuocNhap_Thang2 f = new Frm_TkeThuocNhap_Thang2();
                f.Thang = int.Parse(txtThang.Text);
                f.Nam = int.Parse(txtNam.Text);
                f.ShowDialog();
            }
            else
                XtraMessageBox.Show("Bạn chưa nhập đầy đủ dữ liệu!","Thông Báo",MessageBoxButtons.OK,MessageBoxIcon.Information);
        }

        private void groupControl1_DoubleClick(object sender, EventArgs e)
        {
            frm_TKeCTThuocNhap f = new frm_TKeCTThuocNhap();
            f.TenLoaiThuoc = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Tên Loại Thuốc").ToString();
            f.ShowDialog();
        }

        private void bbi_Refresh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            uc_ThongKe_ThuocNhapTheoThang_Load(sender, e);
        }

    }
}


